Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add CanvasContext #4439

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

feat: add CanvasContext #4439

wants to merge 1 commit into from

Conversation

plagoa
Copy link
Contributor

@plagoa plagoa commented Nov 19, 2024

Adds a HvCanvasContext. Canvas components (SidePanel, BottomPanel and CanvasToolbar) use this context to resize automatically when the side panel is resized. If no CanvasContext is used then the components won't resize automatically and it's up to the user to do that if that's needed.

@plagoa plagoa requested a review from a team as a code owner November 19, 2024 10:54
@plagoa plagoa requested review from zettca and MEsteves22 and removed request for a team November 19, 2024 10:54
@github-actions github-actions bot temporarily deployed to uikit/pr-4439 November 19, 2024 10:58 Destroyed
@github-actions github-actions bot temporarily deployed to uikit-docs/pr-4439 November 19, 2024 10:59 Destroyed
@plagoa plagoa force-pushed the feat/canvas_context branch 2 times, most recently from dd86921 to 7b5fe70 Compare November 19, 2024 11:12
@github-actions github-actions bot temporarily deployed to uikit/pr-4439 November 19, 2024 11:17 Destroyed
@github-actions github-actions bot temporarily deployed to uikit-docs/pr-4439 November 19, 2024 11:17 Destroyed
() => ({
sidePanelOpen,
updateSidePanelOpen,
sidePanelWidth: width,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sidePanelWidth: width,
sidePanelWidth: sidePanelOpen ? width : 0,

@@ -1,5 +1,5 @@
import { useMemo, useState } from "react";
import { cx } from "@emotion/css";
import HvCanvasProvider from "packages/pentaho/src/Canvas/CanvasContext/CanvasContext";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

needs to be exported

Can we hoist CanvasContext.tsx up a directory too? We won't have other files there, and its how we organize other contexts

const HvCanvasProvider = ({ children }: { children: React.ReactNode }) => {
const [sidePanelOpen, setSidePanelOpen] = useState(false);
const [width, setWidth] = useState(0);
const [lastOpenWidth, setLastOpenWidth] = useState(0);
Copy link
Member

@zettca zettca Nov 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is derived state, right? We can compute the actual width with the existing sidePanelOpen and width

eg

const actualWidth = sidePanelOpen ? width : 0

@@ -19,6 +19,7 @@ interface ResizableProps {
initialWidth?: number;
minWidth?: number;
maxWidth?: number;
updateSidePanelWidth?: (width: number) => void;
Copy link
Member

@zettca zettca Nov 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

event handlers should be named as such on*. eg

Suggested change
updateSidePanelWidth?: (width: number) => void;
onResize?: (width: number) => void;

ref={ref}
className={cx(classes.root, className)}
style={{
width: sidePanelOpen
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could do this with CSS vars

Suggested change
width: sidePanelOpen
"--sizePanelWidth": open ? sidePanelWidth : 0,

@plagoa plagoa marked this pull request as draft November 19, 2024 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants